home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 4 / Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso / Development / General / WASTE 1.0a4 Distribution / Interfaces 2 / TextServices.p < prev   
Text File  |  1993-12-21  |  8KB  |  297 lines

  1. unit TextServices;
  2.  
  3. { Pascal interface to the Macintosh Libraries: }
  4. { Text Services Manager }
  5.  
  6. { Based on material copyrighted by Apple Computer, Inc. }
  7. { ANTI© 1993 Merzwaren }
  8.  
  9. interface
  10.     uses
  11.         AppleEvents, Components;
  12.  
  13.     const
  14.  
  15.         gestaltTSMgrVersion = 'tsmv';            { Text Services Manager gestalt selector }
  16.  
  17.         kTSMVersion = 1;                                { version of Text Services Manager }
  18.         kTextService = 'tsvc';                        { component type }
  19.         kInputMethodService = 'inpm';            { component subtype }
  20.  
  21.         bTakeActiveEvent = 15;                    { bit set if component takes activate events }
  22.         bScriptMask = $00007F00;
  23.         bLanguageMask = $000000FF;
  24.         bScriptLanguageMask = bScriptMask + bLanguageMask;
  25.  
  26. { hilite styles }
  27.  
  28.         kCaretPosition = 1;                            { specify caret position }
  29.         kRawText = 2;                                    { specify range of raw text }
  30.         kSelectedRawText = 3;                        { specify range of selected raw text }
  31.         kConvertedText = 4;                            { specify range of converted text }
  32.         kSelectedConvertedText = 5;                { specify range of selected converted text }
  33.  
  34. { Apple Event constants }
  35.  
  36.         kTextServiceClass = kTextService;    { event class }
  37.         kUpdateActiveInputArea = 'updt';    { update active inline area }
  38.         kPos2Offset = 'p2st';                            { convert global coordinates to text offset }
  39.         kOffset2Pos = 'st2p';                            { convert text offset to global coordinates }
  40.         kShowHideInputWindow = 'shiw';    { show or hide the input window }
  41.  
  42. { event keywords }
  43.  
  44.         keyAETSMDocumentRefCon = 'refc';    { TSM document refcon }
  45.         keyAEServerInstance = 'srvi';            { server instance }
  46.         keyAETheData = 'kdat';                        { text }
  47.         keyAEScriptTag = 'sclg';                    { script & language tags }
  48.         keyAEFixLength = 'fixl';                    { length of confirmed text }
  49.         keyAEHiliteRange = 'hrng';                { hilite range array }
  50.         keyAEUpdateRange = 'udng';            { update range array }
  51.         keyAEClauseOffsets = 'clau';                { clause offsets array }
  52.         keyAECurrentPoint = 'cpos';                { current point }
  53.         keyAEDragging = 'bool';                    { dragging flag }
  54.         keyAEOffset = 'ofst';                            { text offset }
  55.         keyAERegionClass = 'rgnc';                { region class }
  56.         keyAEPoint = 'gpos';                            { current point }
  57.         keyAEBufferSize = 'buff';                    { buffer size to get the text }
  58.         keyAERequestedType = 'rtyp';            { requested text type }
  59.         keyAEMoveView = 'mvvw';                { move view flag }
  60.         keyAELength = 'leng';                        { length }
  61.         keyAENextBody = 'nxbd';                    { next or previous body }
  62.  
  63. { optional keywords for Offset2Pos }
  64.  
  65.         keyAETextFont = 'ktxf';
  66.         keyAETextPointSize = 'ktps';
  67.         keyAETextLineHeight = 'ktlh';
  68.         keyAETextLineAscent = 'ktas';
  69.         keyAEAngle = 'kang';
  70.  
  71. { optional keyword for Pos2Offset }
  72.  
  73.         keyAELeftSide = 'klef';
  74.  
  75. { optional keyword for ShowHideInputWindow }
  76.  
  77.         keyAEShowHideInputWindow = 'shiw';
  78.  
  79. { keyword for PinRange }
  80.  
  81.         keyAEPinRange = 'pnrg';
  82.  
  83. { descriptor types }
  84.  
  85.         typeComponentInstance = 'cmpi';
  86.         typeTextRange = 'txrn';
  87.         typeTextRangeArray = 'tray';
  88.         typeOffsetArray = 'ofay';
  89.         typeIntlWritingCode = 'intl';
  90.         typeQDPoint = 'QDpt';
  91.         typeAEText = 'tTXT';
  92.         typeText = 'TEXT';
  93.  
  94. { descriptor type constants }
  95.  
  96.         kTSMOutsideOfBody = 1;
  97.         kTSMInsideOfBody = 2;
  98.         kTSMInsideOfActiveInputArea = 3;
  99.  
  100.         kNextBody = 1;
  101.         kPreviousBody = 2;
  102.  
  103. { Apple Event error constants }
  104.  
  105.         errOffsetInvalid = -1800;
  106.         errOffsetIsOutsideOfView = -1801;
  107.         errTopOfDocument = -1810;
  108.         errTopOfBody = -1811;
  109.         errEndOfDocument = -1812;
  110.         errEndOfBody = -1813;
  111.  
  112. { Text Services Manager result codes }
  113.  
  114.         tsmComponentNoErr = noErr;
  115.         tsmUnsupScriptLanguageErr = -2500;
  116.         tsmInputMethodNotFoundErr = -2501;
  117.         tsmNotAnAppErr = -2502;
  118.         tsmAlreadyRegisteredErr = -2503;
  119.         tsmNeverRegisteredErr = -2504;
  120.         tsmInvalidDocIDErr = -2505;
  121.         tsmTSMDocBusyErr = -2506;
  122.         tsmDocNotActiveErr = -2507;
  123.         tsmNoOpenTSErr = -2508;
  124.         tsmCantOpenComponentErr = -2509;
  125.         tsmTextServiceNotFoundErr = -2510;
  126.         tsmDocumentOpenErr = -2511;
  127.         tsmUseInputWindowErr = -2512;
  128.         tsmTSHasNoMenuErr = -2513;
  129.         tsmTSNotOpenErr = -2514;
  130.         tsmComponentAlreadyOpenErr = -2515;
  131.         tsmInputMethodIsOldErr = -2516;
  132.         tsmScriptHasNoIMErr = -2517;
  133.         tsmUnsupportedTypeErr = -2518;
  134.         tsmUnknownErr = -2519;
  135.  
  136. { data types }
  137.  
  138.     type
  139.  
  140.         TextRange = record
  141.                 fStart: LongInt;
  142.                 fEnd: LongInt;
  143.                 fHiliteStyle: Integer;
  144.             end;
  145.         TextRangePtr = ^TextRange;
  146.         TextRangeHandle = ^TextRangePtr;
  147.  
  148.         TextRangeArray = record
  149.                 fNumOfRanges: Integer;
  150.                 fRange: array[0..0] of TextRange;
  151.             end;
  152.         TextRangeArrayPtr = ^TextRangeArray;
  153.         TextRangeArrayHandle = ^TextRangeArrayPtr;
  154.  
  155.         OffsetArray = record
  156.                 fNumOfOffsets: Integer;
  157.                 fOffset: array[0..0] of LongInt;
  158.             end;
  159.         OffsetArrayPtr = ^OffsetArray;
  160.         OffsetArrayHandle = ^OffsetArrayPtr;
  161.  
  162.         TextServiceInfo = record
  163.                 fComponent: Component;
  164.                 fItemName: Str255;
  165.             end;
  166.         TextServiceInfoPtr = ^TextServiceInfo;
  167.  
  168.         TextServiceList = record
  169.                 fTextServiceCount: Integer;
  170.                 fServices: array[0..0] of TextServiceInfo;
  171.             end;
  172.         TextServiceListPtr = ^TextServiceList;
  173.         TextServiceListHandle = ^TextServiceListPtr;
  174.  
  175.         ScriptLanguageRecord = record
  176.                 fScript: ScriptCode;
  177.                 fLanguage: LangCode;
  178.             end;
  179.  
  180.         ScriptLanguageSupport = record
  181.                 fScriptLanguageCount: Integer;
  182.                 fScriptLanguageArray: array[0..0] of ScriptLanguageRecord;
  183.             end;
  184.         ScriptLanguageSupportPtr = ^ScriptLanguageSupport;
  185.         ScriptLanguageSupportHandle = ^ScriptLanguageSupportPtr;
  186.  
  187.         InterfaceTypeList = array[0..0] of OSType;
  188.  
  189.         TSMDocumentID = Ptr;
  190.  
  191. { Text Services Manager Routines for Client Applications }
  192.  
  193.     function InitTSMAwareApplication: OSErr;
  194.     inline
  195.         $7014, $AA54;
  196.     function CloseTSMAwareApplication: OSErr;
  197.     inline
  198.         $7015, $AA54;
  199.     function NewTSMDocument (numOfInterface: Integer;
  200.                                     var supportedInterfaceTypes: InterfaceTypeList;
  201.                                     var idocID: TSMDocumentID;
  202.                                     refCon: LongInt): OSErr;
  203.     inline
  204.         $7000, $AA54;
  205.     function DeleteTSMDocument (idocID: TSMDocumentID): OSErr;
  206.     inline
  207.         $7001, $AA54;
  208.     function ActivateTSMDocument (idocID: TSMDocumentID): OSErr;
  209.     inline
  210.         $7002, $AA54;
  211.     function DeactivateTSMDocument (idocID: TSMDocumentID): OSErr;
  212.     inline
  213.         $7003, $AA54;
  214.     function TSMEvent (var event: EventRecord): Boolean;
  215.     inline
  216.         $7004, $AA54;
  217.     function TSMMenuSelect (menuResult: LongInt): Boolean;
  218.     inline
  219.         $7005, $AA54;
  220.     function SetTSMCursor (mousePos: Point): Boolean;
  221.     inline
  222.         $7006, $AA54;
  223.     function FixTSMDocument (idocID: TSMDocumentID): OSErr;
  224.     inline
  225.         $7007, $AA54;
  226.     function GetServiceList (numOfInterfaceTypes: Integer;
  227.                                     var supportedInterfaceTypes: InterfaceTypeList;
  228.                                     var serviceInfo: TextServiceListHandle;
  229.                                     var seedValue: LongInt): OSErr;
  230.     inline
  231.         $7008, $AA54;
  232.     function OpenTextService (idocID: TSMDocumentID;
  233.                                     aComponent: Component;
  234.                                     var aComponentInstance: ComponentInstance): OSErr;
  235.     inline
  236.         $7009, $AA54;
  237.     function CloseTextService (idocID: TSMDocumentID;
  238.                                     aComponentInstance: ComponentInstance): OSErr;
  239.     inline
  240.         $700A, $AA54;
  241.     function UseInputWindow (idocID: TSMDocumentID;
  242.                                     useWindow: Boolean): OSErr;
  243.     inline
  244.         $7010, $AA54;
  245.  
  246. { Utilities -- called by the Script Manager }
  247.  
  248.     function SetDefaultInputMethod (ts: Component;
  249.                                     var slRecord: ScriptLanguageRecord): OSErr;
  250.     inline
  251.         $700C, $AA54;
  252.     function GetDefaultInputMethod (var ts: Component;
  253.                                     var slRecord: ScriptLanguageRecord): OSErr;
  254.     inline
  255.         $700D, $AA54;
  256.     function SetTextServiceLanguage (var slRecord: ScriptLanguageRecord): OSErr;
  257.     inline
  258.         $700E, $AA54;
  259.     function GetTextServiceLanguage (var slRecord: ScriptLanguageRecord): OSErr;
  260.     inline
  261.         $700F, $AA54;
  262.  
  263. { Text Services Manager Routines for Components }
  264.  
  265.     function SendAEFromTSMComponent (var theAppleEvent: AppleEvent;
  266.                                     var reply: AppleEvent;
  267.                                     sendMode: AESendMode;
  268.                                     sendPriority: AESendPriority;
  269.                                     timeOutInTicks: LongInt;
  270.                                     idleProc: IdleProcPtr;
  271.                                     filterProc: EventFilterProcPtr): OSErr;
  272.     inline
  273.         $700B, $AA54;
  274.     function NewServiceWindow (wStorage: Ptr;
  275.                                     boundsRect: Rect;
  276.                                     title: Str255;
  277.                                     visible: Boolean;
  278.                                     theProc: Integer;
  279.                                     behind: WindowPtr;
  280.                                     goAwayFlag: Boolean;
  281.                                     ts: ComponentInstance;
  282.                                     var window: WindowPtr): OSErr;
  283.     inline
  284.         $7011, $AA54;
  285.     function CloseServiceWindow (window: WindowPtr): OSErr;
  286.     inline
  287.         $7012, $AA54;
  288.     function GetFrontServiceWindow (var window: WindowPtr): OSErr;
  289.     inline
  290.         $7013, $AA54;
  291.     function FindServiceWindow (thePoint: Point;
  292.                                     var theWindow: WindowPtr): Integer;
  293.     inline
  294.         $7017, $AA54;
  295.  
  296. implementation
  297. end.